import 'package:elevator/model/build_info.dart';
import 'package:elevator/model/lift_info.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

import '../../../../../../../../utils/eventbus.dart';

class ThirdLogic extends GetxController {
   BuildInfo buildInfo = BuildInfo();
   var liftInfo = LiftInfo().obs;

  ThirdLogic(this.buildInfo, LiftInfo lInfo){
    liftInfo.value = lInfo;
  }


   busCallback(arg){
     liftInfo.value = arg;
     liftInfo.refresh();
   }

   @override
   void onClose() {
     debugPrint("ThirdLogic:onClose:liftInfo_${buildInfo.buildId}_${liftInfo.value.order}");
     super.onClose();
   }

   void register(){
     bus.on('${bus.liftInfo_Key}${buildInfo.buildId}_${liftInfo.value.order}', busCallback);
   }

   void unregister(){
     debugPrint("ThirdLogic:unregister:liftInfo_${buildInfo.buildId}_${liftInfo.value.order}");
     bus.off('${bus.liftInfo_Key}${buildInfo.buildId}_${liftInfo.value.order}', busCallback);
   }
}
